<template>
    <div class="teamUsers">
        <breadcrumb
            :breadcrumbItem="breadcrumbItem"
        />
        <div class="from">
            <el-input placeholder="请输入搜索姓名" class="input-with-select" style="width: 33%" >
                <template #append>
                    <el-button type="primary" ><el-icon><Search /></el-icon></el-button>
                </template>
            </el-input>
            <el-button type="primary" @click="dialogFormVisible = true">添加用户</el-button>
            <el-table
                border
                style="width: 100%"
                :data="itemData.value"
            >
                <el-table-column width="80" label="企业号" type="index" />
                <el-table-column width="auto" label="企业名称" prop="teamName" />
                <el-table-column width="auto" label="企业邮箱" prop="email" />
                <el-table-column width="auto" label="员工姓名" prop="teamMembers.first" />
                <el-table-column width="auto" label="入职时间" prop="regtime" />
            </el-table>
        </div>

    </div>
</template>

<script setup>
    import breadcrumb from '@/components/breadCrumb.vue'
    import { reactive,toRefs,ref } from 'vue'
    import moment from "moment"
    import request from '@/utils/request.js'

    import { watchEffect } from 'vue-demi'

    const breadcrumbItem = [
        {
            id:255,
            name:'用户管理'
        },
        {
            id:256,
            name:'团队列表'
        }
    ]

    let dialogFormVisible = ref(false)

    let itemData = reactive([])
    const getData = async function(){
        const {data} = await request.get('user/list')
        itemData.value = data.data
        console.log(itemData.value);
        itemData = itemData.value.map((item) =>{
            let reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})/
            let regs = item.regtime.match(reg)
            if(regs == null){
                item.regtime = moment(item.regtime,moment.ISO_8601).format('YY-MM-DD HH:mm:ss')
            }
        })
    }
    watchEffect(getData)

</script>

<style lang="scss" scoped>
    .myselfUsers{
        padding: 10px;
        .from{
            margin-top: 20px;
            .el-input{
                margin: 0px 10px 10px 0px;
            }
        }
    }
</style>